GBML manual / Drawing

Drawing and the screen

A map of everything that decides what the player sees - sprites, text, backgrounds, the camera, effects and animated tiles - and which page covers which.

What is on the screen

The GBA screen is 240 pixels wide and 160 tall. Everything the player sees on it is drawn from a few different kinds of thing, and each kind has its own rules. This section has one page for each.

You want toReadThe short version
Show a character, an item or a bulletDrawing and the draw orderA sprite is a small picture that belongs to one instance. You choose which one, and what covers what.
Put words or numbers on the screenDrawing textText is a row of small sprites, one per character.
Pin a score or a health bar to a corner of the screenScreen anchorsAn anchor is a named spot on the screen, like the top-left corner. You say "4 pixels in from there" instead of writing a screen-sized number.
Do a sum with the size of the screen, such as centring somethingScreen anchorsscreen_width and screen_height say how many pixels wide and tall the screen is, so you never type the number yourself.
Fill the screen behind everything with a big pictureBackgroundsA background is one large picture the hardware scrolls as a single piece. It is not an instance.
Decide which part of a big room is shownThe cameraThe screen is a window onto a world that can be much bigger. The camera moves the window.
Add sparks, smoke, flames or a dark room lit by torchesEffectsParticle systems and lights, started from code.
Make water, torches or a conveyor belt moveTile animationA tile that cycles through several pictures on its own.

One rule behind all of them

The GBA has a fixed amount of everything. It can draw at most 128 sprites in a single frame, and show at most four backgrounds. A frame is one picture of the game, and the GBA shows about 60 of them a second. Text, effects and health bars are made of sprites too, so they spend from the same 128 as your characters do.

That is why these pages keep coming back to the same limits. Budgets lists all of them in one place.

Where to start

Almost every game begins with Drawing and the draw order, because it explains what happens when you write a Draw event. After that, take the page for whatever you are trying to put on the screen.

See also: Drawing and the draw orderDrawing textScreen anchorsBackgroundsThe cameraEffectsTile animation